﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Lamex.Library;

namespace Lamex.mLabor.UI
{
    public partial class frmLBR_Calendar : frmBaseChild
    {
        public frmLBR_Calendar()
        {
            InitializeComponent();

            //日历看板
            //https://bbs.csdn.net/topics/392271720
            //日历控件中显示内容
            //https://bbs.csdn.net/topics/390180599?list=23555098
            //手把手一步步用DataGridView 控件编写属于自己的日历
            //https://blog.csdn.net/xianfajushi/article/details/8833760?utm_source=distribute.pc_relevant.none-task

        }

        private void frmLBR_Calendar_Resize(object sender, EventArgs e)
        {
            panelRight.Width = this.Width - panelLeft.Width;
            panelLft_Bottom.Height = panelLeft.Height - panelLft_Top.Height;
        }

        private void frmLBR_Calendar_Load(object sender, EventArgs e)
        {
            string[] 日历列 = new string[] { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
            foreach (string 元素 in 日历列)
            {
                DataGridViewTextBoxColumn 列 = new DataGridViewTextBoxColumn();
                列.HeaderText = 元素;
                事件日历.Columns.Add(列);
            }
            事件日历.Rows.Add(6);
            int 计数 = 0;
            int 星期值 = Convert.ToInt16(DateTime.Parse(DateTime.Now.ToString("yyyy年MM月01日")).DayOfWeek);
            int 月天数 = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
            for (int 行 = 0; 行 < 事件日历.RowCount; 行++)
            {
                if (行 > 0) 星期值 = 0;
                for (int 列 = 星期值; 列 < 事件日历.ColumnCount; 列++)
                {
                    计数++;
                    if (计数 > 月天数) 计数 = 1;
                    事件日历.Rows[行].Cells[列].Value = 计数.ToString("00");
                    if (计数 == DateTime.Now.Day) 事件日历.CurrentCell = 事件日历.Rows[行].Cells[列];
                }
            }
            int 上月天数 = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month - 1);
            for (int 列 = 事件日历.ColumnCount - 1; 列 >= 0; 列--)
            {
                if (事件日历.Rows[0].Cells[列].Value == null)
                {
                    事件日历.Rows[0].Cells[列].Value = 上月天数.ToString("00");
                    上月天数--;

                }
            }



        }
    }
}